package hao.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import hao.itheima.entity.PageBean;
import hao.itheima.mapper.LogMapper;
import hao.itheima.pojo.OperateLog;
import hao.itheima.service.LogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class LogServiceImpl implements LogService {

    private static final Logger log = LoggerFactory.getLogger(LogServiceImpl.class);
    @Autowired
    private LogMapper logMapper;

    @Override
    public PageBean findpage(Integer page, Integer pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page, pageSize);
        //2.调用mapper进行查询数据
        List<OperateLog> logList = logMapper.findpage();
        //3.强转成分页对象
        Page<OperateLog> logPage = (Page<OperateLog>) logList; // 强转对象
        //4.构造PageBean对象并返回
        return new PageBean(logPage.getTotal(), logPage.getResult());
    }
}
